package ast_generator;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
/**
 * 
 * @author Chu
 *This class was created soley for  testing the creation of the AST Tree.
 */
public class ASTTest {
/*//static ArrayList<ArrayList<String>> treeArray=new ArrayList<ArrayList<String>>;
	static int size=200;
static ArrayList[] treeArray= new ArrayList[size];

static ArrayList<String> epsilon= new ArrayList<String>();*/

public static void main(String args[])
{
	TreeGenerator.makeTree("TestFile.txt");
}
}




//Code all moved to treeGenerator.java for neatness
/**{
	for( int i=0; i<size; i++ ) treeArray[i]= new ArrayList<String>();
	epsilon.add("epsilon");
 LexScanner scanner=new LexScanner();
 
scanner.generateCharacterClasses("TestFile.txt");
 HashMap<String,ArrayList<String>> characterClasses=scanner.getCharacterClasses();
 HashMap<String,String> tokenMap=scanner.getTokenMap();
//Set<String> keys= tokenMap.keySet();
 Object[] regex= tokenMap.values().toArray();

 /*for(String s:keys){
 }*/
/*
int i=0;
while(i<regex.length)
{
	System.out.println("REGEX: "+(String)regex[i]+ "TOKEN NAME:");
	RecursiveDescentParser Parser=new RecursiveDescentParser((String)regex[i],characterClasses);
	ASTTree
	ASTNode n=Parser.parse();
	convertToArrayList(1,n);
	//System.out.println(treeArray);
	System.out.println();
	i++;
}

System.out.println("done");
}



private static void convertToArrayList(int i,ASTNode n) //note this function creates an ArrayList representation of the tree. Also prints the preorder traversal of the tree
{
	if(n!=null)
	{
	
	
	if(n.getLeft()!=null)
	{
	convertToArrayList(2*i,n.getLeft());
	}
	 if(n.getValue()!=null)
		{
		System.out.print(n.getValue());
		}
	  else
	  {
		   	System.out.print(epsilon);
	  }
	
   if(n.getRight()!=null)
	{
	convertToArrayList(2*i+1,n.getRight());
	}
   if(n.getValue()!=null)
	{
	treeArray[i-1]=n.getValue();
	}
 else
 {
	   	   treeArray[i-1]=epsilon;
 }
   
  
	}
}*/

